package com.bjpowernode.app;
import java.util.InputMismatchException;
import java.util.Scanner;
public class MyApp12 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int index = 0;
        try {
            index = scanner.nextInt();
        } catch (InputMismatchException e) {
            e.printStackTrace();
            System.out.println("你输入的不是数字");
            return;
        }
        MyService myService = new MyService();
        int result = 0;

        //这里需要调用myService.fun1()方法
        //myService.fun1()已经向上抛出异常
        //所有这里需要捕获，如果这里不捕获，则会默认到main方法捕获【JVM会调用main方法】
        try {
            result = myService.fun1(index);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组超标");
        }
        System.out.println("结果为:" + result);
    }
}
